﻿using System;
using System.Text;
using System.Xml;
using Gean.Attributes;
using Pansoft.HIME.Base.Wrapper;

namespace Pansoft.HIME.Base.Entities
{
    /// <summary>描述柜台信息的实体类
    /// </summary>
    [Serializable]
    public class Counter
    {
        /// <summary>构造函数（给窗口编号赋值）
        /// </summary>
        public Counter()
        {
            Index = 0;
            Ranges = new WorkRangeCollection(0);
        }

        public Counter(int counterIndex)
        {
            Index = counterIndex;
        }

        /// <summary>柜台编号索引值
        /// </summary>
        [EntityColumn]
        public int Index { get; set; }

        /// <summary>实体的全局Id，默认采用网点Id+实体缩写+编号方式以保证全局的唯一性
        /// </summary>
        [EntityColumn]
        public string Id { get; set; }

        /// <summary>柜台名称
        /// </summary>
        [EntityColumn]
        public string Name { get; set; }

        /// <summary>助记编号（单网点唯一）
        /// </summary>
        [EntityColumn]
        public string Number { get; set; }

        /// <summary>营业厅分区ID
        /// </summary>
        [EntityColumn]
        public short DistrictId { get; set; }

        /// <summary>
        /// 柜台Ip地址格式如 "127.0.0.1"
        /// </summary>
        [EntityColumn]
        public string IpAddress { get; set; }

        /// <summary>对应的多个工作时间段
        /// </summary>
        [EntityColumn]
        public WorkRangeCollection Ranges { get; set; }

        public override string ToString()
        {
            var sb = new StringBuilder();
            sb.Append("(");
            sb.Append(Index);
            sb.Append(")");
            sb.Append(!string.IsNullOrWhiteSpace(Name) ? Name : " 柜台");
            return sb.ToString();
        }
    }
}